﻿using System;
using System.Collections;
using System.Collections.Generic;

using System.Text;
using System.Web.UI.WebControls;

namespace Module.BusinessLogic
{
    public class ModulTypeBL
    {
        public const int LEFTSIDE = 1;
        public const int RIGHTSIDE = 2;

        private int _ModuleType;
        public int ModuleType
        {
            get { return _ModuleType; }
            set { _ModuleType = value; }
        }
        private string _ModuleName;
        public string ModuleName
        {
            get { return _ModuleName; }
            set { _ModuleName = value; }
        }

        private string _ModuleUrl;
        public string ModuleUrl
        {
            get { return _ModuleUrl; }
            set { _ModuleUrl = value; }
        }
        
        public class TinTuc
        {
            public static int Type = 2;
            public static string TypeName = "Module Tin tức";
            public static string Url = "tin-tuc";
        }
        public class Game
        {
            public static int Type = 3;
            public static string TypeName = "Module Game";
            public static string Url = "Gae";
        }
        public class HinhAnh
        {
            public static int Type = 4;
            public static string TypeName = "Module Hình ảnh";
            public static string Url = "hinh-anh";
        }
        public class VideoClip
        {
            public static int Type = 5;
            public static string TypeName = "Module VideoClip";
            public static string Url = "VideoClip";
        }
        public class LinkUrl
        {
            public static int Type = 7;
            public static string TypeName = "Đặt Link Url";
        }


        #region AddDropList
        public static ArrayList Modul()
        {
            ArrayList _Modul = new ArrayList(15);

            ModulTypeBL md = new ModulTypeBL();
            _Modul.Clear();           

            md = new ModulTypeBL();
            md.ModuleType = TinTuc.Type;
            md.ModuleName = TinTuc.TypeName;
            md.ModuleUrl = TinTuc.Url;
            _Modul.Add(md);

            md = new ModulTypeBL();
            md.ModuleType = Game.Type;
            md.ModuleName = Game.TypeName;
            md.ModuleUrl = Game.Url;
            _Modul.Add(md);

            md = new ModulTypeBL();
            md.ModuleType = HinhAnh.Type;
            md.ModuleName = HinhAnh.TypeName;
            md.ModuleUrl = HinhAnh.Url;
            _Modul.Add(md);

            md = new ModulTypeBL();
            md.ModuleType = VideoClip.Type;
            md.ModuleName = VideoClip.TypeName;
            md.ModuleUrl = VideoClip.Url;
            _Modul.Add(md); 

            return _Modul;
        }

        public static void AddDropList(ListControl DropList)
        {
            for (int i = 0; i < Modul().Count; i++)
            {
                DropList.Items.Add(new ListItem(((ModulTypeBL)Modul()[i]).ModuleName, ((ModulTypeBL)Modul()[i]).ModuleType.ToString()));
            }
        }
        #endregion

        #region GetType
        public static string GetType(string Key)
        {
            for (int i = 0; i < Modul().Count; i++)
            {
                if (((ModulTypeBL)Modul()[i]).ModuleUrl != null)
                {
                    if (((ModulTypeBL)Modul()[i]).ModuleUrl.ToLower() == Key.ToLower())
                    {
                        return ((ModulTypeBL)Modul()[i]).ModuleType.ToString();
                    }
                }
            }
            return "1";
        }
        #endregion

        #region GetUrl
        public static string GetUrl(int _Type)
        {
            for (int i = 0; i < Modul().Count; i++)
            {
                if (((ModulTypeBL)Modul()[i]).ModuleType == _Type)
                {
                    return ((ModulTypeBL)Modul()[i]).ModuleUrl.ToString();
                }
            }
            return "trang-chu";
        }
        #endregion

        #region Get ModulName
        public static string GetName(int type)
        {
            for (int i = 0; i < Modul().Count; i++)
            {
                if (((ModulTypeBL)Modul()[i]).ModuleType == type)
                {
                    return ((ModulTypeBL)Modul()[i]).ModuleName;
                }
            }
            return "Trang khác";
        }
        #endregion
    }
}
